package com.lizemin.controller;

import com.lizemin.constant.Constants;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Objects;

/**
 * @author lzm
 * @date 2025/4/6 12:59
 * @description
 */
@RestController
public class TestController {

    @GetMapping("/heartBeat")
    public String heartBeat() {
        return "ok";
    }

    @GetMapping("/validateLoginStatus")
    public String validateLoginStatus(HttpSession session) {
        Object user = session.getAttribute(Constants.LOGIN_STATUS);
        if (Objects.isNull(user)) {
            throw new RuntimeException("用户未登录");
        }
        return "在线状态";
    }
}
